﻿$(document).ready(function() {
	var parmArr = [];
	var index = 0;
	var recordIndex = 0;
	
    $("#end").click(function() {
    	var itemId = window.ini[index].itemId;
    	var li = $("#tableOUT li:eq(0)");
    	var arr = li.text().split(" ");
    	for(var i=1; i<arr.length; i++) {
            parmArr[recordIndex] = {
                uid: arr[i].trim(),
                iid: itemId,
                lid: lid
            }
            recordIndex++;
    	}
    	console.debug(parmArr);
    	index++;
    });

    // hp-save
    $("#saveBtn").click(function() {
        var loader = layer.load(1);
        $.ajax({
            type: "POST",
            url: getRootPath() + "/lottery/saveLotteryRecord.do",
            data: JSON.stringify(parmArr),
            dataType: "json",
            contentType: 'application/json;charset=utf-8', //设置请求头信息  
            success: function(data) {
                if (data.success) {
                    layer.msg(data.msg);
                    window.location.href = getRootPath() + 'lottery/lotteryCoolResult.do?lid=' + lid;
                } else {
                    layer.alert(data.msg);
                }
                layer.close(loader);
            }
        });
    })
});